﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace Estadio.GameObjects.Helpers
{
    public class KeyboardHandleController : IHandleController
    {
        const float MoveSpeed = 0.2f;
        const float RotSpeed = MathHelper.Pi;
        KeyboardComponent kb;

        Keys keyUp = Keys.D1;
        Keys keyDown = Keys.D2;
        Keys keyLeft = Keys.D3;
        Keys keyRight = Keys.D4;

        public KeyboardHandleController()
            : base()
        {
            kb = InputManager.Instance.KBoard;
        }



        #region IHandleController Members

        public Entity Target { get; set; }

        public float Move()
        {
            float amount = 0;
            if (kb.IsKeyDown(keyUp))
                amount += MoveSpeed;

            if (kb.IsKeyDown(keyDown))
                amount -= MoveSpeed;

            return amount;
        }

        public float Rotate()
        {
            float angle = 0;
            if (kb.IsKeyDown(keyLeft))
                angle += RotSpeed;

            if (kb.IsKeyDown(keyRight))
                angle -= RotSpeed;

            return angle;
        }

        #endregion
    }
}
